-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat:add plugin-lightning #2429
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jimtracy1007! Welcome to the elizaOS community. Thanks for submitting your first pull request; your efforts are helping us accelerate towards AGI. We'll review it shortly. You are now an elizaOS contributor!
@coderabbitai review |
📝 WalkthroughWalkthroughThe pull request introduces a new Lightning Network plugin for the Eliza agent, enabling off-chain payment functionality. The plugin integrates with LND (Lightning Network Daemon) and provides actions for creating and paying invoices. It includes a comprehensive package with TypeScript configurations, provider implementations, and action handlers. The changes extend the agent's capabilities by adding Lightning Network support through a modular and configurable plugin architecture. Changes
Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 12
🧹 Nitpick comments (7)
packages/plugin-lightning/src/actions/payInvoice.ts (2)
82-83
: Redundant 'outgoing_channel' parameterIn
payInvoiceOptions
, passingoutgoing_channel
is unnecessary since it's determined within thepayInvoice
method.
92-95
: Simplify callback messagesYou can streamline the construction of callback messages for clarity.
Consider:
if (payInvoiceResp.is_confirmed) { - text = `Successfully payInvoice ${content.request} from ${payInvoiceResp.outgoing_channel};\r\n Amount: ${payInvoiceResp.tokens};\r\n Fee: ${payInvoiceResp.fee};\r\n Payment Hash: ${payInvoiceResp.id};`; + callback({ + text: `Successfully paid invoice ${content.request} from ${payInvoiceResp.outgoing_channel};\nAmount: ${payInvoiceResp.tokens};\nFee: ${payInvoiceResp.fee};\nPayment Hash: ${payInvoiceResp.id};`, + content: { success: true }, + }); } else { - text = `Failed to payInvoice ${content.request} from ${content.outgoing_channel};\r\n Amount: ${payInvoiceResp.tokens};`; + callback({ + text: `Failed to pay invoice ${content.request} from ${content.outgoing_channel};\nAmount: ${payInvoiceResp.tokens};`, + content: { success: false }, + }); } - callback({ - text: text, - content: { - success: true, - }, - });packages/plugin-lightning/src/index.ts (2)
8-8
: Unused import 'lndProvider'The
lndProvider
import is unused. Remove it to clean up the code.Apply this diff:
-import { lndProvider } from "./providers/lightning";
13-15
: Omit empty arraysThe
evaluators
andservices
arrays are empty. You can omit them for brevity.description: "lightning integration plugin", - providers: [lndProvider], + providers: [], - evaluators: [], - services: [], actions: [createInvoiceAction, payInvoiceAction],packages/plugin-lightning/src/providers/lightning.ts (1)
74-74
: Improve string template formattingThe current string concatenation could be improved.
- return `${agentName}'s Lightning Node publickey : ${nodePubkey}\n,Channel count : ${channels.length}`; + return `${agentName}'s Lightning Node publickey: ${nodePubkey}\nChannel count: ${channels.length}`;packages/plugin-lightning/src/actions/createInvoice.ts (1)
70-70
: Format token amount in success messageRaw token values should be formatted for better readability.
- text: `Successfully createInvoice ${createInvoiceResp.tokens}\r\nInvoice:${createInvoiceResp.request}`, + text: `Successfully created invoice for ${createInvoiceResp.tokens.toLocaleString()} sats\r\nInvoice: ${createInvoiceResp.request}`,packages/plugin-lightning/README.md (1)
38-44
: Add language specifiers to code blocks.Code blocks should specify their language for proper syntax highlighting.
Apply these changes:
- Line 38: Add
text
specifier- Line 53: Add
text
specifier- Line 70-72: Remove empty code block
Also applies to: 53-59, 70-72
🧰 Tools
🪛 Markdownlint (0.37.0)
38-38: null
Fenced code blocks should have a language specified(MD040, fenced-code-language)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (14)
agent/package.json
(1 hunks)agent/src/index.ts
(2 hunks)packages/plugin-lightning/README.md
(1 hunks)packages/plugin-lightning/eslint.config.mjs
(1 hunks)packages/plugin-lightning/package.json
(1 hunks)packages/plugin-lightning/src/actions/createInvoice.ts
(1 hunks)packages/plugin-lightning/src/actions/payInvoice.ts
(1 hunks)packages/plugin-lightning/src/index.ts
(1 hunks)packages/plugin-lightning/src/providers/lightning.ts
(1 hunks)packages/plugin-lightning/src/templates/index.ts
(1 hunks)packages/plugin-lightning/src/types/index.ts
(1 hunks)packages/plugin-lightning/tsconfig.json
(1 hunks)packages/plugin-lightning/tsup.config.ts
(1 hunks)turbo.json
(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- packages/plugin-lightning/eslint.config.mjs
- packages/plugin-lightning/tsconfig.json
🧰 Additional context used
🪛 Markdownlint (0.37.0)
packages/plugin-lightning/README.md
38-38: null
Fenced code blocks should have a language specified
(MD040, fenced-code-language)
53-53: null
Fenced code blocks should have a language specified
(MD040, fenced-code-language)
70-70: null
Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🔇 Additional comments (5)
packages/plugin-lightning/tsup.config.ts (1)
13-22
: Review external dependenciesVerify that all necessary dependencies are correctly externalized to prevent bundling issues.
agent/src/index.ts (1)
857-861
: Verify environment variables before enabling the plugin.The plugin activation depends on three environment variables. Let's verify their presence and format.
turbo.json (1)
52-55
: LGTM!The build configuration follows the established pattern and correctly specifies the dependency on plugin-tee.
agent/package.json (2)
95-95
: LGTM! Dependency properly placed.The new Lightning plugin dependency:
- Uses the correct workspace syntax
- Follows alphabetical ordering
- Is placed in the appropriate dependencies section
95-95
: Verify Lightning plugin security configuration.Since this plugin handles financial transactions, ensure that the required environment variables (
LND_TLS_CERT
,LND_MACAROON
,LND_SOCKET
) are properly secured and not exposed in logs or error messages.Consider implementing:
- Environment variable validation at startup
- Secure error handling that doesn't leak sensitive data
- Rate limiting for invoice creation
can you fix these @jimtracy1007 |
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@coderabbitai mustuse elizaLogger |
Tip For best results, initiate chat on the files or code changes. @wtfsayo Here are the changes needed to use elizaLogger instead of console.log:
import { elizaLogger } from "@elizaos/core";
In elizaLogger.log("payInvoice action handler called");
elizaLogger.log("🚀 ~ payInvoiceResp:", payInvoiceResp); In elizaLogger.log("CreateInvoice action handler called"); 🔗 Analysis chain🏁 Scripts executedThe following scripts were executed for the analysis: Script:
Length of output: 65853 Script:
Length of output: 387 ✏️ Learnings added
|
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Ok,I will fix it. |
…liza into plugin-lightning
Head branch was pushed to by a user without write access
@wtfsayo I have fixed the related issues. Please review and merge them again. Thank you. |
* upstream/develop: test configuration and tests for client-lens (elizaOS#2534) chore(attempt): optimize pnpm cache configuration (elizaOS#2556) feat: add a way to create/store/restore agents in the filesystem (elizaOS#2389) chore: optimize pnpm cache configuration (elizaOS#2555) chore: remove cleanup step from integration tests workflow (elizaOS#2553) feat: Add more actions to Abstract Plugin (elizaOS#2531) feat: add anthropic image provider for vision (elizaOS#2524) feat: improve integrationtests workflow caching (elizaOS#2551) feat: Updated READ.me file with pre-requisites to enable telegram bot (elizaOS#2547) feat(plugin-devin): implement client-agnostic Devin plugin (elizaOS#2549) use generateObject handle undefined env variable feat:add plugin-lightning (elizaOS#2429)
@elizaos/plugin-lightning
This plugin enables create lightning invoice or payInvoice.
Features
Installation
Add the plugin to your Eliza configuration:
Configuration
Set the following environment variables:
Available Actions
1. CREATE_INVOICE
Make a new off-chain invoice.
Examples:
Returns: lnbcrt....
2. PAY_INVOICE
Make an off-chain payment.
Examples:
Security Notes
License
MIT